package com.longrise.co.ui.home.fragment;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.provider.Settings;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.baidu.location.BDLocation;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.co.R;
import com.longrise.co.api.ApiConstants;
import com.longrise.co.api.CommonPara;
import com.longrise.co.ui.carlife.fragment.NewDetailFragment;
import com.longrise.co.ui.carlife.model.NewsBean;
import com.longrise.co.ui.home.adapter.CarCompanyAdapter;
import com.longrise.co.ui.home.contract.HomeContract;
import com.longrise.co.ui.home.model.AreaIdBean;
import com.longrise.co.ui.home.model.BindCarInfo;
import com.longrise.co.ui.home.model.CarCompany;
import com.longrise.co.ui.home.model.CityInfoBean;
import com.longrise.co.ui.home.model.HomeModel;
import com.longrise.co.ui.home.presenter.HomePresenter;
import com.longrise.co.ui.home.presenter.XmlParserImpl;
import com.longrise.co.ui.home.widget.AreaSelectDialog;
import com.longrise.co.ui.login.fragment.LoginFragment;
import com.longrise.co.ui.mine.fragment.CertifiedVehicleFragment;
import com.longrise.co.utils.Constants;
import com.longrise.co.utils.GlideImageLoader;
import com.ly.common.base.BaseFragment;
import com.ly.common.baserx.RxBus;
import com.ly.common.commonutils.StringUtils;
import com.ly.common.commonwidget.LoadingDialog;
import com.ly.common.dialog.DialogOnClickListener;
import com.ly.common.dialog.MDAlertDialog;
import com.ly.common.security.EnCryptDeCrypt2;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerClickListener;
import com.zaaach.citypicker.CityPickerActivity;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import longrise.phone.com.baidulib.baidu.LocationHelper;
import rx.functions.Action1;

/**
 * Created by luoyang on 2017-6-26.
 */

public class HomeFragment extends BaseFragment<HomePresenter, HomeModel> implements HomeContract.HomeView<CarCompany>, OnBannerClickListener, SwipeRefreshLayout.OnRefreshListener, BaseQuickAdapter.RequestLoadMoreListener, BaseQuickAdapter.OnRecyclerViewItemClickListener, View.OnClickListener, LocationHelper.LocationListener, DialogOnClickListener, AreaSelectDialog.OnSelectAreaListener {

    @Bind(R.id.recyclerView)
    RecyclerView recyclerView;
    @Bind(R.id.refresh_layout)
    SwipeRefreshLayout refreshLayout;
    @Bind(R.id.head)
    RelativeLayout head;

    //head
    Banner banner;
    TextView carFileQuery;
    TextView carFileNoCar;
    TextView carNum;
    TextView carFileInfo;
    TextView carMore;
    TextView city;
    //no data tip
    RelativeLayout noDataTip;
    TextView searchNoDataTv;
    ImageView searchIv;

    private List<Object> mImageList;
    private CarCompanyAdapter mAdapter;

    private List<NewsBean.ListBean> mImageContent;

    private View mHeadView;

    private boolean mIsBindCar = false;

    private boolean mIsNewLoad;
    private boolean mIsCarLoad;
    private boolean mIsCompanyLoad;

    private Dialog mLoadingDialog;
    private MDAlertDialog mDialog;
    private MDAlertDialog mChangeCityDialog;
    private AreaSelectDialog mAreaSelectDialog;

    private LocationHelper locationHelper;
    private static final int TWO_MILE = 2 * 1000;
    private static final int SETTING_LOCATION_HOME = 900;
    private static final int REQUEST_CODE_PICK_CITY = 233;
    private EntityBean bean;

    private String mCurrentCity;
    private BDLocation mLocation;

    private boolean mIsFirstLoad = false;
    private String cityName;
    private List<CityInfoBean> mList;
    private CarCompany info;


    @Override
    protected int getLayoutResource() {
        Log.e("abc",""+1);
        return R.layout.common_recylerview;
    }

    @Override
    public void initPresenter() {
        Log.e("abc",""+2);
        mPresenter.setVM(this, mModel);
    }

//    登录之前调这个方法
    @Override
    protected void initView() {
        Log.e("abc",""+3);
        head.setVisibility(View.GONE);
        initHeadView();
        initRecyclerView();
//        登录状态下不走这两个方法!
        getXmlData();
//        locationHelper = new LocationHelper(getContext(), this);//激活定位
//        load();
        mRxManager.on(Constants.RX_EVENT_REFRESH_HOME, new Action1<String>() {
            @Override
            public void call(String s) {
                if("loginSuccess".equals(s)) {
                    onRefresh();
                    return ;
                }
                mIsFirstLoad = true;
            }
        });
    }

//    登陆之后调这个方法
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser && mIsFirstLoad) {
            Log.i("CarFileFragment", "coming CarFileFragment....");
            Log.e("abc",""+4);
            mIsFirstLoad = false;
            onRefresh();
        }
    }

    private void showLoadingDialog() {
        Log.e("abc",""+5);
        if (mLoadingDialog == null) {
            mLoadingDialog = LoadingDialog.showDialogForLoading((Activity) getContext(), "正在加载中...", true);
        }
        mLoadingDialog.show();
    }


    private void initEntityBean() {
        Log.e("abc",""+6);
        if (bean == null) {
            bean = new EntityBean();
        }

        bean.set("pagenum", 1);
        bean.set("pagesize", 5);
        bean.set("raidus", TWO_MILE);
        bean.set("user", CommonPara.getInstance().getUser());
    }


    private void initHeadView() {
        Log.e("abc",""+7);
        mHeadView = LayoutInflater.from(getContext()).inflate(R.layout.fg_home, null);
        banner = (Banner) mHeadView.findViewById(R.id.banner);
        carFileQuery = (TextView) mHeadView.findViewById(R.id.car_file_query);
        carFileNoCar = (TextView) mHeadView.findViewById(R.id.car_file_no_car);
        carNum = (TextView) mHeadView.findViewById(R.id.car_num);
        carFileInfo = (TextView) mHeadView.findViewById(R.id.car_file_info);
        carMore = (TextView) mHeadView.findViewById(R.id.more_car_service);
        city = (TextView) mHeadView.findViewById(R.id.city);
//        setText(city, CommonPara.getInstance().getCity());
        //no data tip
        noDataTip = (RelativeLayout) mHeadView.findViewById(R.id.no_data_tip);
        searchNoDataTv = (TextView) mHeadView.findViewById(R.id.search_no_data_tv);
        searchIv = (ImageView) mHeadView.findViewById(R.id.search_iv);
        noDataTip.setVisibility(View.GONE);
        carFileQuery.setOnClickListener(this);
        carMore.setOnClickListener(this);
        city.setOnClickListener(this);
        initBanner();
        //初始化汽车档案数据

    }

    private void initRecyclerView() {
        Log.e("abc",""+8);
        refreshLayout.setOnRefreshListener(this);
        refreshLayout.setColorSchemeColors(Constants.RECYCLER_RGB);

        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        mAdapter = new CarCompanyAdapter(getContext(), null);
        mAdapter.setOnLoadMoreListener(this);
        mAdapter.openLoadMore(5, true);
        mAdapter.setOnRecyclerViewItemClickListener(this);
        recyclerView.setAdapter(mAdapter);
        mAdapter.addHeaderView(mHeadView);


    }


    public static HomeFragment newInstance() {
        Log.e("abc",""+9);
        return new HomeFragment();
    }

//  附近的修理厂联网获成功回调的方法！
    @Override
    public void requestSuccess(CarCompany info) {
        Log.e("abc",""+10);
        this.info=info;
        if (info != null && info.getList() != null && info.getList().size() > 0) {
            noDataTip.setVisibility(View.GONE);
            mAdapter.setNewData(info.getList());
            mAdapter.notifyDataChangedAfterLoadMore(false);
        } else {
            //没有搜索到结果,(此处后台说如果没有数据的时候我们去加载更多的页面为用户展现附近的服务，暂时还没做)
            noDataTip.setVisibility(View.VISIBLE);
            mAdapter.notifyDataChangedAfterLoadMore(false);

        }
        mIsCompanyLoad = true;
    }

    @Override
    public void onRequestComplete(int type) {
        Log.e("abc",""+11);
        switch (type) {
            case Constants.HOME_LOAD_NEWS:
                mIsNewLoad = false;
                break;
            case Constants.HOME_LOAD_CAR:
                mIsCarLoad = false;
                break;
            case Constants.HOME_LOAD_CARSERVICE:
                mIsCompanyLoad = false;
                break;
        }
//        if(!mIsNewLoad && !mIsCarLoad && !mIsCompanyLoad) {
            if (mLoadingDialog != null && mLoadingDialog.isShowing()) {
                mLoadingDialog.dismiss();
            }
//        }
//        if (refreshLayout.isRefreshing()){
//            refreshLayout.setRefreshing(false);
//        }
        if (!mIsNewLoad && !mIsCarLoad && !mIsCompanyLoad) {
            if (refreshLayout.isRefreshing()) {
                Log.e("abc",""+12);
                refreshLayout.setRefreshing(false);
            }
//
        }
    }

    private void initBanner() {
        mImageList = new ArrayList<>();
    }


    @Override
    public void OnBannerClick(int position) {
        Log.e("abc",""+13);
        if (mImageContent != null && position <= mImageContent.size() && position > 0) {
            NewsBean.ListBean bean = mImageContent.get(position - 1);
            if (bean != null) {
                NewDetailFragment.newInstance(bean);
            }
        }
    }

    private void initDialog() {
        Log.e("abc",""+14);
        mDialog = new MDAlertDialog.Builder(getContext())
                .setContentText("GPS定位功能未开启,是否打开？")
                .setOnclickListener(this)
                .build();
    }

    private void showChangeCityDialog() {
        Log.e("abc",""+15);
//        if (mChangeCityDialog == null) {
//            mChangeCityDialog = new MDAlertDialog.Builder(getContext())
//                    .setContentText("当前城市为" + mCurrentCity + ",是否进行切换？")
//                    .setOnclickListener(new ChangeCityDialogListener())
//                    .build();
//        }
//        mChangeCityDialog.show();
        if(mAreaSelectDialog==null){
            mAreaSelectDialog = new AreaSelectDialog(getContext(),R.style.dialog_style);
            mAreaSelectDialog.setCanceledOnTouchOutside(false);
            mAreaSelectDialog.setCancelable(false);
            mAreaSelectDialog.setOnSelectAreaListener(this);

        }
            mAreaSelectDialog.show();
    }

    @Override
    public void onSelect(int type) {
        switch(type){
            case AreaSelectDialog.SELECT_HN :
                cityName = mList.get(0).getName();
                CommonPara.getInstance().setCity(cityName);
                ApiConstants.setBaseUrl(mList.get(0).getBaseUrl());
                ApiConstants.setUpdateUrl(mList.get(0).getUpdateUrl());
                CommonPara.getInstance().setAreaId(mList.get(0).getAreaid());
                CommonPara.getInstance().setDefaultAreaid(mList.get(0).getAreaid());
                break;
            case AreaSelectDialog.SELECT_ZJ:
                cityName = mList.get(1).getName();
                CommonPara.getInstance().setCity(cityName);
                ApiConstants.setBaseUrl(mList.get(1).getBaseUrl());
                ApiConstants.setUpdateUrl(mList.get(1).getUpdateUrl());
                CommonPara.getInstance().setAreaId(mList.get(1).getAreaid());
                CommonPara.getInstance().setDefaultAreaid(mList.get(1).getAreaid());
                break;
        }
        mAreaSelectDialog.dismiss();
        showLoadingDialog();
        requestHomeNews();
        locationHelper = new LocationHelper(getContext(), this);//激活定位
        load();
    }

//    private class ChangeCityDialogListener implements DialogOnClickListener {
//
//        @Override
//        public void clickLeftButton(View view) {
//            SPUtils.setSharedBooleanData(getActivity(), Constants.SP_KEY_CANCLE, true);
//            requestHomeNews();
//            requestNearCompany();
//            if (mChangeCityDialog != null) {
//                mChangeCityDialog.dismiss();
//            }
//        }

//        @Override
//        public void clickRightButton(View view) {
//            mPresenter.getCityAreaId(mCurrentCity, false);
//            if (mChangeCityDialog != null) {
//                mChangeCityDialog.dismiss();
//            }
//        }
//    }

    @Override
    public void onStart() {
        super.onStart();
        //开始轮播
        banner.startAutoPlay();
    }

    @Override
    public void onStop() {
        super.onStop();
        //结束轮播
        banner.stopAutoPlay();
    }

    @Override
    public void onRefresh() {
        noDataTip.setVisibility(View.GONE);
//        showLoadingDialog();
//        if (info!=null){
//            info.getList().clear();
//            mAdapter.notifyDataSetChanged();
//        }
        requestBindCar();
        requestHomeNews();
        requestNearCompany();
    }

//    开始定位
    private void load() {
        Log.e("abc",""+20);
        noDataTip.setVisibility(View.GONE);
//        mPresenter.getCarCompany(1, ApiConstants.PAGE_SIZE_5, null, null, null, isProcess);
        if (locationHelper != null) {
            locationHelper.start();
        }
//        requestBindCar();
//        mPresenter.getHomeNewsList(1, 5, isProcess);
    }

    private boolean checkLogin() {
        Log.e("abc",""+21);
        boolean isLogin = CommonPara.getInstance().isLogin();
        mIsBindCar = false;
        carFileInfo.setVisibility(View.GONE);
        carNum.setVisibility(View.GONE);
        carFileNoCar.setVisibility(View.VISIBLE);
        carFileQuery.setText("去登录");
        carFileNoCar.setText("您暂无绑定车辆");
        if (isLogin==false){
            if (mLoadingDialog!=null) {
                mLoadingDialog.dismiss();
            }
            if (refreshLayout.isRefreshing()){
                refreshLayout.setRefreshing(false);
            }
        }
        return isLogin;
    }

    @Override
    public void onLoadMoreRequested() {

    }

    @Override
    public void onItemClick(View view, int i) {
        CarCompany.ListBean bean = mAdapter.getItem(i);
        if (bean != null) {
            RxBus.getInstance().post(Constants.RX_EVENT_NEXT_PAGE, CompanyDetailFragment.newInstance(bean.getCompanyid(), bean.getAreaid()));
        }
    }

//    绑定汽车联网成功回调的方法
    @Override
    public void backBindCarList(BindCarInfo bean) {
        if (bean == null || bean.getList() == null || bean.getList().size() == 0) {
            //没有绑定车辆
            Log.e("abc",""+22);
            carFileInfo.setVisibility(View.GONE);
            carNum.setVisibility(View.GONE);
            carFileNoCar.setVisibility(View.VISIBLE);
            carFileQuery.setText("去绑定");
            mIsBindCar = false;

        } else {
            carFileInfo.setVisibility(View.VISIBLE);
            carNum.setVisibility(View.VISIBLE);
            carFileNoCar.setVisibility(View.GONE);
            carFileQuery.setText("查询档案");
            carFileInfo.setText(bean.getList().get(0).getCarno());
            carNum.setText(String.valueOf(bean.getList().size()));
            mIsBindCar = true;
        }
    }

//   加载轮播图成功回调的方法
    @Override
    public void backHomeNewsList(NewsBean bean) {
        if (bean == null || bean.getList().size() == 0) {
            return;
        }
        mImageContent = bean.getList();
        mImageList.clear();
        Log.e("abc",""+23);
        for (NewsBean.ListBean news : bean.getList()) {
            if (!StringUtils.isEmpty(news.getImgtitle())) {
                mImageList.add(news.getImgtitle());
            } else {
                mImageList.add(R.drawable.banner_car);
            }
        }
        //轮播设置
        banner.setImages(mImageList)
                .setImageLoader(new GlideImageLoader())
                .setOnBannerClickListener(this)
                .start();
        mIsNewLoad = true;
    }

    @Override
    public void backAreaId(AreaIdBean bean) {
//        showLongToast("切换成功");
//        setText(city, mCurrentCity);
        Log.e("abc",""+24);
        CommonPara.getInstance().setCity(mCurrentCity);
        if (bean != null && !StringUtils.isEmpty(bean.getAreaid())) {
            CommonPara.getInstance().setAreaId(bean.getAreaid());
        }
        requestNearCompany();
        requestBindCar();
    }

    @Override
    public void onClick(View v) {

        if (v.getId() == R.id.car_file_query) {
            //查询档案  or 绑定
            if (mIsBindCar) {
                //查询档案
                mRxManager.post(Constants.RX_EVENT_QXDA, 1);
            } else {
                //绑定车辆
                if (CommonPara.getInstance().isLogin()) {
                    mRxManager.post(Constants.RX_EVENT_NEXT_PAGE, CertifiedVehicleFragment.newInstance());
                } else {
                    mRxManager.post(Constants.RX_EVENT_NEXT_PAGE, LoginFragment.newInstance());
                }
            }
        } else if (v.getId() == R.id.more_car_service) {
            //更多
            mRxManager.post(Constants.RX_EVENT_NEXT_PAGE, CompanyQueryFragment.newInstance());
        } else if (v.getId() == R.id.city) {
            //选择城市
            startActivityForResult(new Intent(getActivity(), CityPickerActivity.class),
                    REQUEST_CODE_PICK_CITY);
        }
    }

//    @Override
//    public void onActivityResult(int requestCode, int resultCode, Intent data) {
//        if (requestCode == REQUEST_CODE_PICK_CITY && resultCode == RESULT_OK) {
//            if (data != null) {
//                mCurrentCity = data.getStringExtra(CityPickerActivity.KEY_PICKED_CITY);
//                //切换城市
//                if (!StringUtils.isEmpty(mCurrentCity)) {
//                    mPresenter.getCityAreaId(mCurrentCity, false);
//                }
//            }
//        }
//    }

    private void requestNearCompany() {
        Log.e("abc",""+16);
        if (bean == null) {
            initEntityBean();
        }
        if (mLocation == null) {
            noDataTip.setVisibility(View.VISIBLE);
            return;
        }
        if(TextUtils.isEmpty(CommonPara.getInstance().getAreaId())){
            showLongToast("服务器异常，请稍后再试");
            return;
        }
        if(checkLogin()){
            bean.set("latitude", CommonPara.getInstance().getLatitude());
            bean.set("longitude",CommonPara.getInstance().getLongitude());
            String userAreaid = CommonPara.getInstance().getUserAreaid();
            bean.set("areaid", userAreaid);
            try {
                String enUserAreaid = EnCryptDeCrypt2.getInstance().EnCrypt(userAreaid);
                bean.set("sign", enUserAreaid);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else{
            for (int i = 0; i < mList.size(); i++) {
                if(cityName.equals(mList.get(i).getName())){
                    bean.set("latitude",mList.get(i).getLat());
                    bean.set("longitude",mList.get(i).getLog());
                    String areaid = mList.get(i).getAreaid();
                    bean.set("areaid", areaid);
                    try {
                        String enAreaid = EnCryptDeCrypt2.getInstance().EnCrypt(areaid);
                        bean.set("sign",enAreaid);
                    } catch (Exception e) {
                        e.printStackTrace();
                        showLongToast("获取区域信息失败");
                    }
                }
            }
        }
        mPresenter.getNearByCompanyList(bean, false);
    }

    private void requestHomeNews() {
        Log.e("abc",""+17);
        mIsNewLoad = true;
        mPresenter.getHomeNewsList(1, 5, false);
    }

    private void requestBindCar() {
        if (checkLogin()) {
            Log.e("abc",""+18);
            CommonPara.getInstance().setCity(cityName);
            mIsCarLoad = true;
            mPresenter.getBindCarList(null);
        }
    }

//    定位成功后需要判断定位成功后的地址是否与刚开始进入时选定的地址一致
    @Override
    public void locationSuccess(BDLocation location) {
        Log.e("abc",""+19);
        if (location == null) {
            return;
        }
        if(mLoadingDialog!=null){
            mLoadingDialog.dismiss();
        }
        mLocation = location;
        mCurrentCity = location.getCity();
        CommonPara.getInstance().setLatitude(String.valueOf(mLocation.getLatitude()));
        CommonPara.getInstance().setLongitude(String.valueOf(mLocation.getLongitude()));
//        当定位所在的城市名称跟刚开始选择的城市信息一致的话调用真实的位置信息去获取附近企业的信息！
        if(mCurrentCity!=null) {
            if (mCurrentCity.equals(CommonPara.getInstance().getCity())) {
//            for (int i = 0; i < mList.size(); i++) {
//                if(mCurrentCity.equals(mList.get(i).getName())){
//                    CommonPara.getInstance().setAreaId(mList.get(i).getAreaid());
//                }
//            }
                requestBindCar();//获取绑定车辆
                requestNearCompany();//获取定位附近的企业
            } else {
//            当定位所在的城市不是刚开始选择的城市的时候，用真实的位置信息去获取附近的企业列表
                if (!StringUtils.isEmpty(mCurrentCity)) {
                    mPresenter.getCityAreaId(mCurrentCity, false);
                }
            }
//        requestHomeNews();//获取轮播图
//        requestBindCar();//获取绑定的车辆
//        boolean isUserCancel = SPUtils.getSharedBooleanData(getActivity(), Constants.SP_KEY_CANCLE);
//        if (mCurrentCity != null && !mCurrentCity.equals(CommonPara.getInstance().getCity()) && !isUserCancel) {
////            showChangeCityDialog();
//            return;
//        }

        }
    }

//    定位失败后，用sp中存储的地址的数据去加载修理厂信息！
    @Override
    public void locationFail() {
//        showErrorTip("定位失败，未搜索到附近企业");
        showLoadingDialog();
        requestBindCar();
        requestHomeNews();
        requestNearCompany();
    }

    @Override
    public void showGpsDialog() {
        if (mDialog == null) {
            initDialog();
        }
        mDialog.show();
    }

    @Override
    public void clickLeftButton(View view) {
        if (mDialog != null) {
            mDialog.dismiss();
        }
        showErrorTip("搜索附近维修企业失败，请开启位置信息开关。");
    }

    @Override
    public void clickRightButton(View view) {
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        startActivityForResult(intent, SETTING_LOCATION_HOME);
        if (mDialog != null) {
            mDialog.dismiss();
        }
    }

//    进入app时需要判断当前是否有记录过登录的城市
    public void isSelectedCity() {
        if(!checkLogin()){
            CommonPara.getInstance().setCity(null);
        }
        cityName = CommonPara.getInstance().getCity();
        if(TextUtils.isEmpty(cityName)||cityName==""){
//            没有城市的时候调用弹框选择城市
            showChangeCityDialog();
        }else{
//            有城市的时候
            if(mList!=null&&mList.size()>0){
                for (int i = 0; i < mList.size(); i++) {
                    if(mList.get(i).getName().equals(cityName)){
                        ApiConstants.setBaseUrl(mList.get(i).getBaseUrl());
                        ApiConstants.setUpdateUrl(mList.get(i).getUpdateUrl());
                        showLoadingDialog();
                        requestHomeNews();
                        locationHelper = new LocationHelper(getContext(), this);//激活定位
                        load();
                    }
                }
            }
        }
    }

//    解析xml中的数据
    public void getXmlData() {
        InputStream is = null;
        try {
            //通过assertmanager的open方法获取到beauties.xml文件的输入流
            is = getActivity().getAssets().open("cityinfo.xml");
            //初始化自定义的实现类BeautyParserImpl
            XmlParserImpl pbp = XmlParserImpl.newInstance();
            //调用pbp的parse()方法，将输入流传进去解析，返回的链表结果赋给beautyList
            mList = pbp.parse(is);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            XmlParserImpl.close(is);
            isSelectedCity();
        }
    }

    @Override
    public void showErrorTip(String msg) {
        if(msg.equals("未查到对应数据")){
            if (info!=null){
                info.getList().clear();
                mAdapter.notifyDataSetChanged();
            }
            mIsCompanyLoad = true;
            noDataTip.setVisibility(View.VISIBLE);
        }else{
            super.showErrorTip(msg);
        }

    }
}
